package com.ffdms.mobileoffice;

import java.util.List;

import com.ffdms.mobileoffice.MessageAdapter.ViewHolder;
import com.ffdms.service.MessageDigest;
import com.ffdms.util.MobileOfficeUtil;
import com.ffdms.vo.Notice;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NoticeListAdapter extends BaseAdapter {
	private Context context;
	private List<Notice> notices;
	public NoticeListAdapter(Context context, List<Notice> notices){
		this.context = context;
		this.notices = notices;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return this.notices.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return this.notices.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.notice_item_view, null);
			holder = new ViewHolder();

			convertView.setTag(holder);

			holder.tv_notice_title = (TextView) convertView
					.findViewById(R.id.tv_notice_title);
			holder.tv_notice_time = (TextView) convertView
					.findViewById(R.id.tv_notice_time);

		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		Notice notice = notices.get(position);
		holder.tv_notice_title.setText(notice.getTitle());
		String d = notice.getTime();
		holder.tv_notice_time.setText(d);
		return convertView;
	}
	
	static class ViewHolder {
		TextView tv_notice_title;
		TextView tv_notice_time;
	}

}
